/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.io.IOException;
import java.util.Scanner;
import org.openymsg.network.AccountLockedException;
import org.openymsg.network.FailedLoginException;
import org.openymsg.network.LoginRefusedException;
import org.openymsg.network.Session;
import org.openymsg.network.SessionState;
import org.openymsg.network.Status;
import org.openymsg.network.YahooProtocol;

/**
 *
 * @author phuctv
 */
public class Main {

    public static void main(String[] args) throws IllegalStateException, IOException, AccountLockedException, LoginRefusedException, FailedLoginException, InterruptedException {



        Scanner in = new Scanner(System.in);
        System.out.println("ENTER NAME AND PASSWORD:");

        System.out.print("username: ");
        String username = in.nextLine();
        System.out.print("password: ");
        String password = in.nextLine();
        String to, mes;
        Session session = new Session();
        session.setStatus(Status.IDLE);
        session.login(username, password);
        MessageAdaptor messageAdaptor = new MessageAdaptor();
        if (session != null && session.getSessionStatus() == SessionState.LOGGED_ON) {
            session.addSessionListener(messageAdaptor);
            for (String string : session.getCookies()) {
                System.out.println(string);
            }

            session.acceptFriendAuthorization("acllorst", YahooProtocol.YAHOO);
            //session.acceptFriendAuthorization("acllorst", YahooProtocol.YAHOO);
            session.sendNewFriendRequest("acllorst", "user");
            session.requestPicture("eagle_rising6885");
            System.out.print("TO: ");
            to = in.nextLine();
            if (to.equals("quit")) {
                session.logout();
                return;
            }
            System.out.print("MESSAGE: ");
            mes = in.nextLine();
            if (mes.equals("buzz")) {
                session.sendBuzz(to);
            } else {
                session.sendMessage(to, mes);
            }
        }
    }
}

